package com.hsj.pojo;

import java.util.HashSet;
import java.util.Set;

/**
 * @author:Teacher黄
 * @date:Created at 2018/11/14
 */
public class Role {
    private int id;
    private String roleName;
    private String roleDesc;
    /**
     * 多对多配置
     */
    private Set<Access> accesses = new HashSet<Access>();


    /**
     * 一对多配置(一方), 角色里面的用户
     * hibernate里面规定用set来表示多
     */
    private Set<User> users = new HashSet<User>();


    public Role() {
    }

    public Set<Access> getAccesses() {
        return accesses;
    }

    public void setAccesses(Set<Access> accesses) {
        this.accesses = accesses;
    }

    public Set<User> getUsers() {
        return users;
    }

    public void setUsers(Set<User> users) {
        this.users = users;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRoleDesc() {
        return roleDesc;
    }

    public void setRoleDesc(String roleDesc) {
        this.roleDesc = roleDesc;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Role role = (Role) o;

        if (id != role.id) return false;
        if (roleName != null ? !roleName.equals(role.roleName) : role.roleName != null) return false;
        if (roleDesc != null ? !roleDesc.equals(role.roleDesc) : role.roleDesc != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (roleName != null ? roleName.hashCode() : 0);
        result = 31 * result + (roleDesc != null ? roleDesc.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Role{" +
                "id=" + id +
                ", roleName='" + roleName + '\'' +
                ", roleDesc='" + roleDesc + '\'' +
                ", accesses=" + accesses +
                '}';
    }
}
